<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head >
<#include "/page/include.ftl">
</head>
<link href="${rc.contextPath}/static/ajax/libs/jquery-layout/jquery.layout-latest.css" rel="stylesheet"/>
<link href="${rc.contextPath}/static/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css" rel="stylesheet"/>

<body class="gray-bg">
	<div class="container-div ui-layout-center">
		<div class="row">
			
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
	        	<a class="btn btn-success" onclick="$.operate.add()" >
	                <i class="fa fa-plus"></i> 新增
	            </a>
	           
	           
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
         
	<script src="${rc.contextPath}/static/ajax/libs/jquery-layout/jquery.layout-latest.js"></script>
	<script src="${rc.contextPath}/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js"></script>
	<script >
	    
		var editFlag = "";
		var removeFlag = "";
		var resetPwdFlag = "";
		var datas = "";
		var prefix = ctx + "http";
       
		$(function() {
			$('body').layout({ west__size: 185 });
			querymqList();
		});

		function querymqList() {
		    var options = {
		        url: prefix + "/grid",
		        createUrl: prefix + "/add",
		        updateUrl: prefix + "/edit/{id}",
		        removeUrl: prefix + "/remove",
		        exportUrl: prefix + "/export",
		        sortName: "createTime",
		        pageNumber : 1, //初始化加载第一页
                pagination : true,//是否分页
                pageSize : 10,//单页记录数
                striped:true,
		        sortOrder: "desc",
		        modalName: "http客户端管理",
		        search: false,
		        showExport: false,
		        columns: [
		        
		        {
		            field: 'name',
		            title: '任务名称'
		        },
		        {
		            field: 'methodtype',
		            title: '请求类型'
		           
		        },
		        {
                    field: 'url',
                	title: '请求地址'

                },
		        {
		            field: 'sysname',
		            title: '系统名称',
		            visible: false
		        },
		        
		        {
		            field: 'cronexpress',
		            title: '作业表达式'
		        },

		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
		                 actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-edit"></i>删除</a> ');
		                  
		                //actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="startjob(\'' + row.id + '\')"><i class="fa fa-remove"></i>启动</a> ');
		                //actions.push('<a class="btn btn-info btn-xs ' + resetPwdFlag + '" href="#" onclick="stopjob(\'' + row.id + '\')"><i class="fa fa-key"></i>停止</a>');
		                return actions.join('');
		            }
		        }]
		    };
		    $.table.init(options);
		    
		}
		
		
		
		function startjob(id){
		   $.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "file/start",
        		data : {
        			"id":id
        		},
        		async : false,
        		error : function(request) {
        		console.log(request);
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        		$.modal.msgSuccess(data.msg);
        		//console.log(data);
        		$.table.refresh();
        			//$.operate.successCallback(data);
        		}
        	});
		}
		
		function stopjob(id){
		   $.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "http/stop",
        		data : {
        			"id":id
        		},
        		async : false,
        		error : function(request) {
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        		//console.log(data);
        		$.modal.msgSuccess(data.msg);
        		$.table.refresh();
        			//$.operate.successCallback(data);
        		}
        	});
		}
		
		

		
	</script>
</body>
</html>